/**
 * 邮箱后缀自动提示
 */
var availableTagsDef = ["@qq.com","@163.com","@126.com","@sina.com","@gmail.com","@foxmail.com","@sohu.com","@vip.qq.com","@hotmail.com","@163.net","@sina.com.cn","@139.com","@189.cn"];
var availableTags = ["@qq.com","@163.com","@126.com","@sina.com","@gmail.com","@foxmail.com","@sohu.com","@vip.qq.com","@hotmail.com","@163.net","@sina.com.cn","@139.com","@189.cn"];
function emailOnkeyUp(obj){
	for( var i = 0; i < availableTags.length; i++) {
		var reg = new RegExp(/\*[@]\*$/);
		if(reg.test(obj.value)){
			availableTags[i] = obj.value+availableTagsDef[i];
		}
	}
}

/**
 * 设置按钮的正在处理效果
 */
//function setButtonInProcess(buttonId){
//	
//	var btn = document.getElementById(buttonId);
//	btn.style.background = "#656d78";
//	btn.style.border = "1px solid #656d78";
//	btn.disabled = "disabled";
//	if(buttonId=='LoginPreDivSubmit'||'loginBtn'==buttonId){
//		btn.value=languageJson['loginloading'];//登录中
//		return;
//	}
//	btn.value=languageJson['loading'];//正在处理
//}
/**
 * 设置 正在处理按钮 的 处理完毕状态
 * @param buttonId
 * @param value
 */
function setButtonFinish(buttonId, value){
	
	var btn = document.getElementById(buttonId);
	btn.style.background = "#10ac86";
	btn.style.border = "1px solid #10ac86";
	btn.disabled = "";
	btn.value = value;
}

function checkIsPhone(){
	var regName = document.getElementById("regName").value;
	if(!checkMobile(regName)){
		document.getElementById("nationli").style.display = "none";
	}else{
		document.getElementById("nationli").style.display = "block";
	}
}

/**
 * 校验邀请码是否为空
 * @returns {Boolean}
 */
function checkInvitationCodeNull()
{
	var invitationCode = trim(document.getElementById("invitationCode").value);
	if(invitationCode==''){
		var desc = languageJson["coinOkRegInvitationCodeNull"];
		$("#invitationCode").focus();
		setTip("invitationCode", "invitationCodeSpan", desc, false);
		$("#invitationCodeSpan").css({'width':'282px'});
		buttonGray('submitBtn', false);
		return false;
	}
	return true;
}

/**
 * 校验邀请码
 */
function checkInvitationCode(){
	var buttonValue = document.getElementById("submitBtn").value;
	setButtonInProcess('submitBtn');
	setTip("invitationCode", "invitationCodeSpan", '', true);

	var invitationCode = trim(document.getElementById("invitationCode").value);
	if(checkInvitationCodeNull()){
		var url = "/user/reg/checkInvitationCode.do?random="+Math.random();
		$.post(url,{'invitationCode':invitationCode},function(result){
			if(result!=null){
				if(result.resultCode!=0){
					okcoinTipAlert("invitationCode", "invitationCodeSpan", result);
					$("#invitationCodeSpan").css({'width':'282px'});
				}else {
					window.location.href="/user/reg/showReg.do?invitationCode="+invitationCode;
				}
			}else {
				okcoinAlert("系统繁忙，请稍后再试！");
			}
		}, 'json');
	}
	setButtonFinish("submitBtn", buttonValue);
}

/**
 * 验证注册用户名
 */
function checkRegName(){
	
	var regName = trim(document.getElementById("regName").value);
	var desc=""; //反馈提示语
	if(regName==''){
		return;
	}
	if(regName.indexOf(" ")>-1){
		desc = languageJson["coinOkRegNameSpaceError"];
	}else if(!checkEmail(regName)){//是否为手机号或者邮箱格式
		desc = languageJson["coinOkRegNameError"];
	}else if (new RegExp("[,]","g").test(regName)){ 
		desc = languageJson["coinOkRegNameCharsError"]; 
	}else if(regName.length>100){//长度不能大于100
		desc = languageJson["coinOkRegNameLengthError"];
	}else {
		var regokcoin = /^([a-zA-Z0-9_-])+@bihang+(.[a-zA-Z0-9_-])+/; 
		if(regokcoin.test(regName.toLowerCase())){
			desc = languageJson["coinOkRegNameCharsError"];
		}
	}
	//错误信息
	if(desc != ""){
		setTip("regName", "regNameSpan", desc,false);
		return false;
	}else{
		setTip("regName", "regNameSpan", "",true);
	}
	//检测用户名是否存在
	var url = "/user/reg/checkRegName.do?name="+encodeURI(regName)+"&random="+Math.round(Math.random()*100);
	$.get(url,{type:0},function(result){
		if(result.resultCode == 0){
			setTip("regName", "regNameSpan", "", true);
			return true; 
		}else {
			okcoinTipAlert("regName","regNameSpan",result);
			if(result.errorNum >= 5){
				if(result.errorNum < 20){
					document.getElementById("captchaInputLi").style.display = "block";
					document.getElementById("captchaIconLi").style.display = "block";
					document.getElementById("ranCode").setAttribute("src", "/user/captcha.do?type=2");
				}else{
					document.getElementById("captchaInputLi").style.display = "none";
					document.getElementById("captchaIconLi").style.display = "none";
					document.getElementById("ranCode").setAttribute("src", "");
				}
			}
			return false;
		}
		},'json');
}

/**
 * 检查验证码格式
 */
function checkMsgCode()	{
	var msgCode = $('#msgCode').val();
	var desc = '';
	if (msgCode == '' || !msgCode) {
		return false;
	}
	
	if (msgCode.length !== 6 || isNaN(msgCode)) {
		desc = languageJson['coinOkNumberCodeLengthError'];
	}
	
	if (desc != '') {
		setTip('msgCode', 'msgCodeSpan', desc, false);
		return false;
	} else {
		setTip('msgCode', 'msgCodeSpan', desc, true);
	}
	
	return true;
}

/**
 * check密码的格式是否正确
 */
function checkPassword(){
	//document.getElementById("capStatus2").style.display = "none";//验证码
	var pwd = trim(document.getElementById("password").value);
	var desc='';
	if(pwd==''){
		return;
	}
	 if (pwd.length < 6 || pwd.length > 30) {
		desc = languageJson["coinOkRegPasswordLengthError"];
	} /*else if (!/[a-zA-Z]/.test(pwd) || !/[0-9]/.test(pwd) || !/[^0-9a-zA-Z]/.test(pwd)) {
		desc = coinOkRegPasswordRequiredError; // 密码至少应包含一个数字、字母和特殊字符
	}*/ 
	
	if(desc != ""){
		setTip('password', 'passwordSpan', desc, false);
		return false;
	}else{
		setTip('password', 'passwordSpan', desc, true);
	}
	
	return true;
	
}
//首页的checkPassword
function checkPasswordIndex(pwdId, inputClassName){
	var pwd = trim(document.getElementById(pwdId).value);
	var desc='';
	
	if (pwd == "") {
		desc = languageJson["coinOkRegPasswordNullError"];
	} 
	
	if(desc != ""){
		setTip(pwdId, pwdId+"Span", desc, false);
		return false;
	}else{
		setTip(pwdId, pwdId+"Span", desc, true);
	}
	return true;
}

/**
 * check重复密码与密码是否一致
 */
function checkRePassword(){
	//document.getElementById("capStatus3").style.display = "none";
	var pwd = trim(document.getElementById("password").value);
	var rePwd = trim(document.getElementById("repassword").value);
	var desc='';
	if(rePwd==''){
		return;
	}
	if(pwd != rePwd){
		desc = languageJson['coinOkRegRePasswordEqualsError'];
	}
	if(desc!=""){
		setTip("repassword", "repasswordSpan", desc,false);
		return false;
	}else{
		setTip("repassword", "repasswordSpan", desc,true);
		return true;
	}
	
}

/**
 * 验证 表单中 用户名
 */
function checkLoginNameNoCheckExist(){
	
	var loginName = trim(document.getElementById("regName").value);
	var desc=""; //反馈提示语
	var regexp = new RegExp("^[0-9]+$");
	if(loginName==''){
		return;
	}
	if(loginName.indexOf(" ")>-1){
		desc = languageJson["coinOkRegNameSpaceError"];
	}else if(!checkEmail(loginName) && !loginName.match(regexp)){//是否为手机号或者邮箱格式
		desc = languageJson["error52"];
	}else if (new RegExp("[,]","g").test(loginName)){ 
		desc = languageJson["coinOkRegNameCharsError"]; 
	}else if(loginName.length>100){//长度不能大于100
		desc = languageJson["coinOkRegNameLengthError"];
	}else {
		var regokcoin = /^([a-zA-Z0-9_-])+@bihang+(.[a-zA-Z0-9_-])+/; 
		if(regokcoin.test(loginName.toLowerCase())){
			desc = languageJson["coinOkRegNameCharsError"];
		}
	}
	//错误信息
	if(desc != ""){
		setTip("regName", "regNameSpan", desc,false);
		return false;
	}else{
		setTip("regName", "regNameSpan", desc,true);
	}
	return true;
}

//首页的OnBlur提示
function checkLoginNameIndex(nameId, inputClassName){
	
	var loginName = trim(document.getElementById(nameId).value);
	var desc=""; //反馈提示语
	
	if(loginName.indexOf(" ")>-1){
		desc = languageJson["coinOkRegNameSpaceError"];
	}else if(loginName == ''){
		desc = languageJson["coinOkRegNameNullError"];
	}else if(!checkEmail(loginName) && !checkMobile(loginName)){//是否为手机号或者邮箱格式
		desc = languageJson["coinOkRegNameError"];
	}else if (new RegExp("[,]","g").test(loginName)){ 
		desc = languageJson["coinOkRegNameCharsError"]; 
	}else if(loginName.length>100){//长度不能大于100
		desc = languageJson["coinOkRegNameLengthError"];
	}/*else {
		var regokcoin = /^([a-zA-Z0-9_-])+@okcoin+(.[a-zA-Z0-9_-])+/; 
		if(regokcoin.test(loginName.toLowerCase())){
			desc = coinOkRegNameCharsError;
		}
	}*/
	//错误信息
	if(desc != ""){
		setTip(nameId, nameId+"Span", desc, false);
		return false;
	}else{
		setTip(nameId, nameId+"Span", desc, true);
	}
	return true;
}
/**
 * check验证码的格式
 */
function checkCode(){
	var code = document.getElementById("code").value;
	if(code == null || code == ''){
		setTip("code", "codeSpan", '', true);
		return true;
	}
	if(code.length!=4){
		setTip("code", "codeSpan", languageJson["coinOkForgotPasswordCodeError"], false);
		return false;
	}else{
		setTip("code", "codeSpan", '', true);
	}
	return true;
}
/**
 * 重设密码|第一步 点击提交
 */
function forgotStepOneSubmit(){
	
	var ids = ["regName","code"];
	var errorid = checkMultiInputNotNull(ids);
	if(errorid != ''){
		if(errorid=='regName'){
			setTip("regName", "regNameSpan", languageJson["findPassName"], false);
			return;
		}
		setTip("code", "codeSpan", languageJson["coinOkForgotPasswordCodeError"], false);
		return false;
	}
	if(checkLoginNameNoCheckExist() && checkCode()){
		
		setButtonInProcess("forgotOneButton");
		
		var regUserName = trim(document.getElementById("regName").value);
		var codeNum = trim(document.getElementById("code").value);
		var url = "/user/reg/findPassword.do?random="+Math.round(Math.random()*100);
		var param = {regName:regUserName,code:codeNum};
		$.get(url,param,function(result){
			reloadcode(1);//刷新验证码
			if(result.resultCode == 0 || result.resultCode == -118){
				window.location.href = "/user/reg/stepConfirm.do";
			}else if(result.resultCode == 2){//跳转到手机验证页面
				window.location.href = "/user/reg/showForgotPwd.do";
			}else if(result.resultCode == -39){
				setButtonFinish("forgotOneButton", languageJson['next']);
				okcoinTipAlert("code","codeSpan",result);
			}else{
				setButtonFinish("forgotOneButton", languageJson['next']);
				okcoinTipAlert("regName","regNameSpan",result);
			}
		},'json');
	}
}
/**
 * 手机号重设密码 | 验证码提交
 */
function checkPhoneVerifyCodeSubmit(){
	setTip("phoneCode", "phoneCodeSpan", "", true);
	var phoneCode = trim(document.getElementById("phoneCode").value);
	var phone = trim(document.getElementById("phone").value);
	if(!checkMobile(phone)){
		okcoinAlert("非法请求");
		return ;
	}
	if(phoneCode.length!=6){
		setTip("phoneCode", "phoneCodeSpan", languageJson["coinOkNumberCodeLengthError"], false);
	}else{
		setButtonInProcess("forgotTwoButton");
		var url = "/user/reg/checkPhoneVerifyCode.do?random="+Math.round(Math.random()*100);
		var param = {phone:phone,code:phoneCode};
		$.get(url,param,function(result){
			
			setButtonFinish("forgotTwoButton", "提交验证");
			if(result!=null){
				if(result.resultCode == 0){
					window.location.href = "/user/reg/showResetPassword.do";
				}else{
					okcoinTipAlert("phoneCode", "phoneCodeSpan", result);
				} 
			}
		},'json');
	}
}

/**
 * 重新发送重设密码的邮件
 */
//function resendForgotPwdEmail(){
//	
//	var email = document.getElementById("resetEmail").value;
//	if(email == null || email.trim()==""){
//		okcoinAlert(languageJson["pwdresetmailsend"],null,null,languageJson['confirmbut']);
//	}
//	var param = {resetEmail:email};
//	var url = "/user/reg/resendForgotPwdEmail.do?random="+Math.round(Math.random()*100);
//	
//	jQuery.post(url, param, function(data){
//		var result = eval('(' + data + ')');
//		if (result != null) {
//			if (result.resultCode == 0) {//发送成功
//				okcoinAlert(languageJson["pwdresetmailsend"],null,null,languageJson['confirmbut']);
//			}else if(result.resultCode == -4){
//				okcoinAlert(languageJson["userActiveEmailRequestIsSofast"]);
//			}else{//TODO 不同错误返回码的不同处理方法
//				okcoinAlert(languageJson["coinOkSystemError"]);
//			}
//		}
//	});
//}

/**
 * 重新发送注册激活的邮件
 */
//function resendRegisterEmail(){
//	
//	var url = "/user/reg/sendRegEmail.do?random="+Math.round(Math.random()*100);
//	
//	jQuery.post(url, null, function(data){
//		var result = eval('(' + data + ')');
//		if (result != null) {
//			if (result.resultCode == 0) {//发送成功
//				okcoinAlert(languageJson["userActiveEmailSendSuccess"],null,null,languageJson['confirmbut']);
//			}else if(result.resultCode == -2){
//				okcoinAlert(languageJson["userActiveEmailRequestIsSofast"]);
//			}else{//TODO 不同错误返回码的不同处理方法
//				okcoinAlert(languageJson["coinOkSystemError"]);
//			}
//		}
//	});
//}

/**
 * 重设密码|第二步 点击提交
 */
//function forgotStepTwoSubmit(){
//	if(checkPassword() && checkRePassword() ){
//		setButtonInProcess("resetPwdButton");
//		//修改密码
//		var pwd = trim(document.getElementById("password").value);
//		var repwd = trim(document.getElementById("repassword").value);
//		var phoneCode = trim(document.getElementById("phoneCode").value);
//		var googleCode = trim(document.getElementById("googleCode").value);
//		var url = "/user/reg/resetPassword.do?random="+Math.round(Math.random()*100);
//		var param = {newPassword:pwd,newPassword2:repwd,googleCode:googleCode,phoneCode:phoneCode};
//		
//		jQuery.get(url,param,function(data){
//			if(data.resultCode==0){
//				//修改成功
//				window.location.href = "/user/reg/passwordChangeConfirm.do";
//			}else{
//				setButtonFinish("resetPwdButton", "完成");
//				returnCheck(data);
//			}
//		},'json');
//	}
//}

/**
 * 首页 用户登陆
 */
//function loginSubmit(){
//	
//	setButtonInProcess('loginBtn');
//	$("#indexErrorSpan").html("");
//	
//	var name = trim(document.getElementById("regName").value);
//	var pwd = trim(document.getElementById("password").value);
//	
//	var desc='';
//	
//	if(name=='' || (!checkEmail(name) && !checkNumber(name))){
//		if(!document.all){//ie浏览器下不要聚焦，否则没有提示信息
//			$("#regName").focus();
//		}
//		desc = languageJson["coinOkLoginNameError"];
//	}else if(pwd == ""){
//		if(!document.all){//ie浏览器下不要聚焦，否则没有提示信息
//			$("#password").focus();
//		}
//		desc = languageJson['coinOkLoginPassNull'];
//	}
//	if(desc != ''){
//		$("#indexErrorSpan").html(desc);
//		setButtonFinish('loginBtn', languageJson['coincommonjs75']);
//		return;
//	}
//	
//	var url = "/user/login/index.do?random="+Math.round(Math.random()*100);
//	var param = {loginName:name,password:pwd};
//	
//	$.post(url,param,function(result){
//		if(result!=null){
//			if(result.resultCode==0){//登陆成功
//				forward = $("#forwardUrl").val();
//				if( forward == null || ""==forward){					
//					window.location.href = "/index.do";
//				}else{
//					forward = decodeURI(forward);
//					window.location.href=forward;
//				}
//			}else if(result.resultCode==1){//登陆进行GOOGLE验证
//				$("#twiceLoginName").html(name);
//				showPreAddDiv();
//			}else{//登陆失败
//				setButtonFinish('loginBtn', languageJson['coincommonjs75']);
//				$("#password").val('').focus();
//				var content = '';
//				var keyId = Math.abs(result.resultCode);
//				var key = "error" + keyId;
//				if(keyId==19||keyId==22||keyId==109||keyId==27){
//					if(result.errorNum > 0){
//						content = languageJson[key]+languageJson['comma']+languageJson['coinOkYourHave']+result.errorNum+languageJson['coinOkChance'];
//					}else if(Math.abs(result.resultCode)==19){
//						content = languageJson["blindphonejs8"];
//					}else if(Math.abs(result.resultCode)==22){
//						content = languageJson["blindphonejs11"];
//					}else{
//						content = languageJson["coincommonjs5"];
//					}
//				}else{
//					content = languageJson[key];
//				}
//				$("#indexErrorSpan").html(content);
//				return;
//			}
//		}
//	},'json');
//}

/**
 * 首页 用户登陆
 */
function loginSubmit4mPayOrderStemp2(){
	setTip("regName", "regNameSpan", '', true);
	setTip("password", "passwordSpan", '', true);
	
	var name = trim(document.getElementById("regName").value);
	var pwd = trim(document.getElementById("password").value);
	var buttonid = trim(document.getElementById("buttonid").value);
	
	var desc='';
	
	if(name==''){
		desc= languageJson['coinOkLoginNameNull'];
		setTip("regName", "regNameSpan", desc, false);
		return;
	}
	
	if((!checkEmail(name) && !checkNumber(name))){
		setTip("regName", "regNameSpan", languageJson["coinOkLoginNameError"], false);
		return;
	}
	
	
	if (pwd == "") {
		desc = languageJson['coinOkLoginPassNull'];
	}
	
	if(desc != ''){
		setTip("password", "passwordSpan", desc, false);
		return;
	}
	var url = "/user/login/index.do?random="+Math.round(Math.random()*100);
	var param = {loginName:name,password:pwd};
	
	jQuery.post(url,param,function(result){
//		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode==0){//登陆成功
//				forward = document.getElementById("forwardUrl").value;
//				if( forward == null || ""==forward){					
					window.location.href = "/merchant/mPayOrderStemp2.do?buttonid=" + buttonid;
//				}else{
//					forward = decodeURI(forward);
//					window.location.href=forward;
//				}
			}else if(result.resultCode==1){//登陆进行GOOGLE验证
				document.getElementById("twiceLoginName").innerHTML = name;
				showPreAddDiv();
			}else{//登陆失败
				okcoinTipAlert("regName", "regNameSpan", result);
				return;
			}
		}
	},'json');
}

/**
 * 首页弹层登录 操作
 */
function loginSubmitOnPreDiv(){
	
	setButtonInProcess('LoginPreDivSubmit');
	document.getElementById("divloginName").className="infoInput_login borderNormal userImage";
	document.getElementById("divpassword").className="infoInput_login borderNormal passwordImage";
	document.getElementById("divloginNameSpan").className="";
	document.getElementById("divpasswordSpan").className="";
	document.getElementById("divloginNameSpan").innerHTML="";
	document.getElementById("divpasswordSpan").innerHTML="";
	
	var name = trim(document.getElementById("divloginName").value);
	var pwd = trim(document.getElementById("divpassword").value);
	if(name==''){
		document.getElementById("divloginName").focus();
		document.getElementById("divloginName").className = "infoInput_login borderRed userImage";
		document.getElementById("divloginNameSpan").className = "errorCueContent";
		document.getElementById("divloginNameSpan").innerHTML = languageJson['coinOkLoginNameNull'];
		$("#divloginNameSpan").css({'width':'232px'});
		setButtonFinish('LoginPreDivSubmit', languageJson['coincommonjs75']);
		return;
	}
	if((!checkEmail(name) && !checkNumber(name))){
		document.getElementById("divloginName").className = "infoInput_login borderRed userImage";
		document.getElementById("divloginNameSpan").className = "errorCueContent";
		document.getElementById("divloginNameSpan").innerHTML = languageJson['coinOkLoginNameError'];
		$("#divloginNameSpan").css({'width':'232px'});
		setButtonFinish('LoginPreDivSubmit', languageJson['coincommonjs75']);
		return;
	}
	if(pwd==""){
		document.getElementById("divpassword").focus();
		document.getElementById("divpassword").className = "infoInput_login borderRed passwordImage";
		document.getElementById("divpasswordSpan").className = "errorCueContent";
		document.getElementById("divpasswordSpan").innerHTML = languageJson['coinOkLoginPassNull'];
		$("#divpasswordSpan").css({'width':'232px'});
		setButtonFinish('LoginPreDivSubmit', languageJson['coincommonjs75']);
		return;
	}
	var url = "/user/login/index.do?random="+Math.round(Math.random()*100);
	var param = {loginName:name,password:pwd};
	buttonGray('LoginPreDivSubmit', true);
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode==0){//登陆成功
				forward = document.getElementById("forwardUrl").value;
				if( forward == null || ""==forward){					
					window.location.href = "/index.do";
				}else{
					forward = decodeURI(forward);
					window.location.href=forward;
				}
			}else if(result.resultCode==1){//登陆进行GOOGLE验证
				/*document.getElementById("twiceLoginName").innerHTML = name;
				document.getElementById("preAddLoginDiv").style.display = "none";
				showPreAddDiv();*/
				window.location.reload(true);
			}else{//登陆失败
				var desc = "";
				if(result.resultCode==-36){
					desc = languageJson['coinOkLoginParamsWrongError'];
				}else if(result.resultCode==-34){
					desc = languageJson['coinOkIpLimitError'];
				}else if(result.resultCode==-109){
					if(result.errorNum == 0){
						desc = languageJson['coinOkIpLimitError'];
					} else {
						desc = languageJson['error109']+languageJson['comma']+languageJson['coinOkYourHave']+result.errorNum+languageJson['coinOkChance'];
					}
				}else if(result.resultCode==-10){
					desc = languageJson["coinOkBrowerCookieNotOpenError"];
				}else{
					desc = languageJson["error"+Math.abs(result.resultCode)];
				}
				$("#divpassword").val('').focus();
				//setTip("divloginName", "divloginNameSpan", desc, false);
				document.getElementById("divloginName").className = "infoInput_login borderRed userImage";
				document.getElementById("divloginNameSpan").className = "errorCueContent";
				document.getElementById("divloginNameSpan").innerHTML = desc;
				$("#divloginNameSpan").css({'width':'232px'});
				setButtonFinish('LoginPreDivSubmit', languageJson['coincommonjs75']);
				
				return;
			}
		}
	});
}

/**
 * 支付登录
 */
function payLogin(){
	
	document.getElementById("regName").className="textInput borderNomal";
	document.getElementById("password").className="textInput borderNomal";
	document.getElementById("regNameSpan").className="";
	document.getElementById("passwordSpan").className="";
	document.getElementById("regNameSpan").innerHTML="";
	document.getElementById("passwordSpan").innerHTML="";
	
	var name = trim(document.getElementById("regName").value);
	var pwd = trim(document.getElementById("password").value);
	if((!checkEmail(name) && !checkNumber(name))){
		setTip("regName", "regNameSpan", languageJson["coinOkRegNameError"], false);
		return;
	}
	
	var desc='';
	if (pwd == "") {
		desc = languageJson['coinOkRegPasswordNullError'];
	}
	
	if(desc != ''){
		setTip("password", "passwordSpan", desc, false);
		return;
	}
	var url = "/user/login/index.do?random="+Math.round(Math.random()*100);
	var param = {loginName:name,password:pwd};
	
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode==0){//登陆成功
//				forward = document.getElementById("forwardUrl").value;
//				if( forward == null || ""==forward){					
//					window.location.href = "/index.do";
//				}else{
//					forward = decodeURI(forward);
//					window.location.href=forward;
//				}
				
			}else if(result.resultCode==1){//登陆进行GOOGLE验证
				document.getElementById("twiceLoginName").innerHTML = name;
				showPreAddDiv();
			}else{//登陆失败
				var desc = "";
				if(result.resultCode==-36){
					desc = languageJson["coinOkLoginParamsWrongError"];
				}else if(result.resultCode==-34){
					desc = languageJson["coinOkIpLimitError"];
				}else if(result.resultCode==-35){
					if(result.errorNum == 0){
						desc = languageJson["coinOkIpLimitError"];
					} else {
						desc = languageJson["coinOkLoginFaildError"]+languageJson['comma']+languageJson["coinOkYourHave"]+result.errorNum+languageJson["coinOkChance"];
						$("#password").val('').focus();
					}
				}else if(result.resultCode==-10){
					desc = coinOkBrowerCookieNotOpenError;
				}else{
					desc = result;
				}
				document.getElementById("regName").className = "textInput borderRed";
				document.getElementById("regNameSpan").className = "errorCueContent";
				document.getElementById("regNameSpan").innerHTML = desc;
				return;
			}
		}
	});
}

/**
 * 登陆时谷歌验证
 */
function totpCodeSubmit4mPayOrderStemp2(){
	setTip('totpCode', 'totpCodeSpan', '', true);
	var buttonid = trim(document.getElementById("buttonid").value);
	var totpCode = trim(document.getElementById("totpCode").value);
	if(totpCode=="" || totpCode.length!=6 ){//不是6位数字的有效验证码格式
		setTip('totpCode', 'totpCodeSpan', "请输入正确的谷歌验证码格式", false);
		return;
	}
	//提交
	var url = "/user/login/submitTotpCode.do?random="+Math.round(Math.random()*100);
	var param = {totpCode:totpCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=null){
			if(result.resultCode==0){//登陆成功
//				forward = document.getElementById("forwardUrl").value;
//				if( forward == null || ""==forward){					
				window.location.href = "/merchant/mPayOrderStemp2.do?buttonid=" + buttonid;
//				}else{
//					forward = decodeURI(forward);
//					window.location.href=forward;
//				}
			}else{
				var desc = '';
				//登陆失败
				var keyId = Math.abs(result.resultCode);
				var key = "error" + keyId;
				var desc = '';
				if(result.resultCode == -20){
					desc = languageJson["error20"];
				}else if(result.resultCode == -21){
					desc = languageJson[key];
				}else if(result.resultCode == -22){
					desc = languageJson[key]+languageJson['comma']+languageJson['coinOkYourHave']+result.errorNum+languageJson['coinOkChance'];
				}else if(Math.abs(result.resultCode)==13){
					desc = languageJson["error13"];
				}else if(result.resultCode==-23){
					desc = languageJson[key];
				}else if(result.resultCode==-101){
					desc = languageJson["error101"];
				}else{
					desc = languageJson["error39"];
				}
				setTip('totpCode', 'totpCodeSpan', desc, false);
				return;
			}
		}
	});
}

/**
 * 登陆时谷歌验证
 */
function totpCodeSubmit(){
	setButtonInProcess('totpSubmitBtn');
	setTip('totpCode', 'totpCodeSpan', '', true);
	
	var totpCode = trim(document.getElementById("totpCode").value);
	if(totpCode=="" || totpCode.length!=6 ){//不是6位数字的有效验证码格式
		setTip('totpCode', 'totpCodeSpan', languageJson['error20'], false);
		setButtonFinish('totpSubmitBtn', languageJson['confirm']);
		return;
	}
	//提交
	var url = "/user/login/submitTotpCode.do?random="+Math.round(Math.random()*100);
	var param = {totpCode:totpCode};
	jQuery.post(url,param,function(data){
		var result = eval('(' + data + ')');
		if(result!=''){
			if(result.resultCode >= 0){//登陆成功
				forward = document.getElementById("forwardUrl").value;
				if( forward == null || ""==forward){					
					window.location.href = "/index.do";
				}else{
					forward = decodeURI(forward);
					window.location.href=forward;
				}
			}else{//登陆失败
				var keyId = Math.abs(result.resultCode);
				var key = "error" + keyId;
				var desc = '';
				if(result.resultCode == -20){
					desc = languageJson["error20"];
				}else if(result.resultCode == -21){
					desc = languageJson[key];
				}else if(result.resultCode == -22){
					desc = languageJson[key]+languageJson['comma']+languageJson['coinOkYourHave']+result.errorNum+languageJson['coinOkChance'];
				}else if(Math.abs(result.resultCode)==13){
					desc = languageJson["error13"];
				}else if(result.resultCode==-23){
					desc = languageJson[key];
				}else if(result.resultCode==-101){
					desc = languageJson["error101"];
				}else{
					desc = languageJson["error39"];
				}
				setTip('totpCode', 'totpCodeSpan', desc, false);
				setButtonFinish('totpSubmitBtn', languageJson['confirm']);
				return;
			}
		}
	});
}

/**
 * 注册邮箱提交
 */
function regEmailSubmit(){
	
	var ids = ['regName','password','repassword'];
	var cresult = checkMultiInputNotNull(ids);
	if(cresult!=''){
		setTip(cresult, cresult+"Span", languageJson['inputIsNull'], false);
	}
	if(checkLoginNameNoCheckExist() && checkPassword() && checkRePassword()){

		var buttonId = "submitBtn";
		buttonGray(buttonId, true);
		var regUserName = trim(document.getElementById("regName").value);
		var pwd = trim(document.getElementById("password").value);
		var nation = trim(document.getElementById("nation").value);
		var codeNum = trim(document.getElementById("code").value);
		var invitationCodeNum = trim(document.getElementById("invitationCode").value);
		
		var url = "/user/reg/index.do?random="+Math.round(Math.random()*100);
		
		var param = {regName:regUserName,password:pwd,nation:nation,code:codeNum,invitationCode:invitationCodeNum};
		
		jQuery.post(url, param, function(result){
			if(result.resultCode < 0){
				buttonGray(buttonId, false);
				//注册失败，显示错误信息 提示
				if(result.resultCode == -39){
					okcoinTipAlert("code", "codeSpan",result);
				}else{
					okcoinTipAlert("regName", "regNameSpan", result);
				}
				if($("#isCaptcha").val() != 0){
					reloadcode(2);//刷新验证码
				}
			}else if(result.resultCode == 0){
				//注册成功
				window.location.href = "/index.do";
			}
		},'json');
	}else {
		return;
	}
}
/**
 * 手机注册提交
 */
function regPhoneSubmit(){
	var ids = ['fromphone','msgCode','password','repassword'];
	var cresult = checkMultiInputNotNull(ids);
	if(cresult!=''){
		setTip(cresult, cresult+"Span", languageJson['inputIsNull'], false);
		return;
	}
	if(checkMsgCode() && checkPassword() && checkRePassword()){
		var buttonId = "submitBtn";
		buttonGray(buttonId, true);
		
		var countrycode = $("#countrycode").val();
		var fromphone = $("#fromphone").val();
		var msgCode = $('#msgCode').val().trim();
		var pwd =  $("#password").val();
		var nation =  $("#nation").val();
		var codeNum = $("#code").val();
		var invitationCodeNum = $("#invitationCode").val();
		
		var url = "/user/reg/index.do?random="+Math.round(Math.random()*100);
		
		var params = {
				countrycode: countrycode,
				fromphone: fromphone,
				msgCode: msgCode,
				password: pwd,
				nation: nation,
				code: codeNum,
				invitationCode: invitationCodeNum
			};
		
		$.post(url, params, function(result){
			if(result.resultCode < 0){
				buttonGray(buttonId,false);
				if(result.resultCode == -105||result.resultCode == -106){
					//注册失败
					okcoinTipAlert("fromphone","fromphoneSpan",result);
				}else if(result.resultCode == -107){
					//注册失败
					okcoinTipAlert("password","passwordSpan",result);
				}else if(result.resultCode == -39){
					okcoinTipAlert("code", "codeSpan",result);
				}else if(result.resultCode == -19 || result.resultCode == -34 || result.resultCode == -17) {
					okcoinTipAlert("msgCode","msgCodeSpan",result);
				}else{
					//注册失败
					okcoinTipAlert("fromphone","fromphoneSpan",result);
				}
			} else if(result.resultCode == 0){
				//注册成功，直接跳转到主页面
				var mainpage = "/index.do";
				window.location.href = mainpage;
			}
		},'json');
	}
}
/**
 * 控制按钮变灰色
 * @param id  按钮id
 * @param bool true灰色；false解除灰色
 */
var buttonGray = function (id,bool){
	var btn = $("#"+id);
	if(bool){
		btn.attr('disabled',true);
		btn.css({"background":"#656d78","border":"1px solid #656d78"});
	}else{
		btn.attr('disabled',false);
		btn.css({"background":"","border":""});
	}
}


/**
 * check是否为邮箱格式
 */
function checkEmail(email){
	filter=/^([a-zA-Z0-9_\-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
	if(!filter.test(trim(email))){
		return false;
	}else{
		return true;
	}
}
/**
 * check是否为手机号格式
 */
function checkMobile(mobile){
	filter=/^1[3|4|5|8|7][0-9]\d{8}$/;
	if(!filter.test(trim(mobile))){
		return false;
	}else{
		return true;
	}
}
/**
 * check是否为数值类型
 */
function checkNumber(num){
	filter=/^-?([1-9][0-9]*|0)(\.[0-9]+)?$/;
	if(!filter.test(trim(num))){
		return false;
	}else{
		return true;
	}
}
/**
 * AJAX加载国家列表
 */
function loadNations(languageType){
	var type = 0;
	if (languageType) {
		type = languageType;
	}
	var url = "/user/getNationsList.do?languageType=" + type + "&random="+Math.round(Math.random()*100);
	 jQuery.get(url,null,function(data){
		$("#nation").append(data);
	});
}
/**
 * 重载验证码图片
 */
function reloadcode(type){
	
	var verify = document.getElementById('ranCode');
	if(type==1){
	    verify.setAttribute('src','/user/captcha.do?type=1&it='+Math.random());
	}else{
	    verify.setAttribute('src','/user/captcha.do?type=2&it='+Math.random());
	}
}
/**
 * 
 * @param type 验证码作用类型 0：找回登陆密码
 * @param elemId 元素ID
 * @param codeType 验证码类型  0：文字验证码 1：语音验证码
 */
//var sendPhoneCodeTimer = 121;
function sendPhoneVerifyCode(type,codeType){
	
	document.getElementById("phoneNumberCode").disabled="disabled";
	document.getElementById("phoneVoiceCode").disabled="disabled";
	document.getElementById("phoneNumberCode").className="unDisabled";
	document.getElementById("phoneVoiceCode").className="unDisabled";
	if(type=='1'){
		document.getElementById("phoneNumberCode").style.margin="0px 17px 0px 0px";
	}
	var phone = trim(document.getElementById("phone").value);
	if(!checkNumber(phone)){
		okcoinAlert(languageJson["coinOkParamError"]);
		return;
	}
	
	if(codeType == 1){
		//先禁用 验证码发送按钮
		document.getElementById("phoneNumberCode").className="unDisabled";
		document.getElementById("phoneVoiceCode").className="unDisabled";
		document.getElementById("phoneNumberCode").disabled="disabled";
		document.getElementById("phoneVoiceCode").disabled="disabled";
		if(type==1){
			document.getElementById("phoneNumberCode").style.margin="0px 17px 0px 0px";
			document.getElementById("phoneNumberCode").style.padding="0px";
			document.getElementById("phoneVoiceCode").style.padding="0px";
		}
		//开始倒计时
		for(var num=1;num<=secs;num++) {
			window.setTimeout("updatePhoneCodeNumber(" + num + ","+type+","+codeType+")", num * 1000);
		}
		
	}
	if(phone == 0 || phone == ''){
		if(codeType!=1){
			if(type == 0 || type==1 || type==13 || type == 59){
				document.getElementById("phoneNumberCode").className="unDisabled";
				document.getElementById("phoneVoiceCode").className="unDisabled";
				document.getElementById("phoneNumberCode").disabled="disabled";
				document.getElementById("phoneVoiceCode").disabled="disabled";
				for(var num=1;num<=secs;num++) {
					window.setTimeout("updatePhoneCodeNumber(" + num + ","+type+","+codeType+")", num * 1000);
				}
			}
			if(type==1){
				document.getElementById("phoneNumberCode").style.margin="0px 17px 0px 0px";
				document.getElementById("phoneNumberCode").style.padding="0px";
			}
		}
	}else {
		var url = "/user/login/sendPhoneVerifyCode.do?random="+Math.round(Math.random()*100);
		var param ={type:type,msgType:codeType,phone:phone};
		jQuery.post(url,param,function(data){
			if(data == 0){//验证码发送成功
				if(codeType!=1){
					
					if(type == 0 || type==1 || type==13 || type == 59){
						document.getElementById("phoneNumberCode").className="unDisabled";
						document.getElementById("phoneVoiceCode").className="unDisabled";
						document.getElementById("phoneNumberCode").disabled="disabled";
						document.getElementById("phoneVoiceCode").disabled="disabled";
						for(var num=1;num<=secs;num++) {
							window.setTimeout("updatePhoneCodeNumber(" + num + ","+type+","+codeType+")", num * 1000);
						}
					}
					if(type==1){
						document.getElementById("phoneNumberCode").style.margin="0px 17px 0px 0px";
						document.getElementById("phoneNumberCode").style.padding="0px";
					}
				}
				setTip('phoneCode', 'phoneCodeSpan', '', true);
			}else if(data==1){
				if(codeType!=1){
					okcoinAlert(languageJson["coinOkParamError"]);
				}
			}else{
				var desc = "";
				if(data==-1){
					desc = languageJson['coinOkSystemError']+"200";
				}else if(data==-2){
					desc = languageJson['coinOkSystemError'];+"201";
				}else if(data==-3){
					desc = languageJson['coinOkRequestLimitError'];
				}else if(data==-43){
					desc = languageJson['coinOkRequestLimitError'];
				}else{
					desc = languageJson['coinOkSystemError'];
				}
				okcoinAlert(desc);
				if(codeType != 1){
					document.getElementById("phoneNumberCode").className="smsCode";
					document.getElementById("phoneVoiceCode").className="voiceCode";
					document.getElementById("phoneNumberCode").value = languageJson["numberCode"];
					document.getElementById("phoneVoiceCode").value = languageJson["voiceCode"];
					document.getElementById("phoneNumberCode").disabled="";
					document.getElementById("phoneVoiceCode").disabled="";
					if(type==1){
						document.getElementById("phoneNumberCode").style.padding="0px 0px 0px 20px";
					}
				}
				//setTip('phoneCode', 'phoneCodeSpan', desc, false);
			}
		});
	}
}
/**
 * 倒计时
 * @param num
 */
function updatePhoneCodeNumber(num,type,codeType){
	if (num == secs) {
		document.getElementById("phoneNumberCode").className="smsCode";
		document.getElementById("phoneVoiceCode").className="voiceCode";
		document.getElementById("phoneNumberCode").value = languageJson["numberCode"];
		document.getElementById("phoneVoiceCode").value = languageJson["voiceCode"];
		document.getElementById("phoneNumberCode").disabled="";
		document.getElementById("phoneVoiceCode").disabled="";
		if(type==1){
			document.getElementById("phoneNumberCode").style.padding="0px 0px 0px 20px";
		}
	} else {
		var times = secs - num;
		if(codeType!=1){
			
			if(languageJson['languagetype']=='0'){
				document.getElementById("phoneNumberCode").value= times +languageJson["sendCodeTimer"];
			}else if(languageJson['languagetype']=='1'){
				document.getElementById("phoneNumberCode").value= languageJson["sendCodeTimer"]+" "+times+" seconds";
			}else{
				document.getElementById("phoneNumberCode").value= times +languageJson["sendCodeTimer"];
			}

		}else{
			
			if(languageJson['languagetype']=='0'){
				document.getElementById("phoneVoiceCode").value= times +languageJson["sendCodeTimer"];
			}else if(languageJson['languagetype']=='1'){
				document.getElementById("phoneVoiceCode").value= languageJson["sendCodeTimer"]+" "+times+" seconds";
			}else{
				document.getElementById("phoneVoiceCode").value= times +languageJson["sendCodeTimer"];
			}

		}
		
	}
}


/**
 * 检查手机短信或google 还有邮箱是否绑定
 */
function securityCheck(security){
	if(security==3){ //话费充值
		window.location.href = "/application/recharge/showPhoneRecharge.do";
	}else if(security==4){ //计划付款
		window.location.href = "/pay/showPlanPaymentList.do";
	}else if(security==5){ //计划收款
		window.location.href = "/pay/showPlanReceiveList.do";
	}else if(security==6){ //地址监控
		window.location.href = "/pay/showAddressTracker.do";
	}else if(security==7){ //小额购币
		window.location.href = "/pay/showBuyBitcoin.do";
	}else if(security==8){ //微博打赏
		window.location.href = "/pay/showRewardsEnter.do";
	}else if(security==1){
		
		window.location.href="/pay/showCreateReceivePayOrder.do";
	}else if(security==2){
		window.location.href="/pay/showCreatePayOrder.do";
	}else{
		window.location.href="/pay/securityCheck.do?type="+security;
	}
}

/**
 * 显示google验证DIV
 */
function showPreAddDiv(){
	dialogBoxShadow(false);
	document.getElementById("preAddDiv").style.display = "block";
	addMoveEvent("preAddDiv_title","preAddDiv");
	document.getElementById('totpCode').focus();
}
/**
 * 页面跳转JS
 */
//function showLoginPreDiv(type){
//	dialogBoxShadow(false);
//	document.getElementById("preAddLoginDiv").style.display = "block";
//	addMoveEvent("preAddLoginDiv_title","preAddLoginDiv");
//	document.getElementById('divloginName').focus();
//	if(type == 1){//保险柜
//		document.getElementById("forwardUrl").value = "/onchain/index.do";
//	}else if(type == 2){//商家工具
//		document.getElementById("forwardUrl").value = "/merchant/index.do";
//	}else if(type == 3){//开放平台
//		document.getElementById("forwardUrl").value = "/open/index.do";
//	}
//}
function showLoginPreDiv(type){
	if(type == 0){
		window.location.href = "/user/login/login.do";
	}else if(type == 4){
		window.location.href = "/wallet/create.do";
	}else if(type == 5){
		window.location.href = "/user/reg/showReg.do";
	}else if(type == 6){
		window.location.href = "/open/start.do";
	}
}

function loadIndex(obj){
	if(obj==1){
		showPreAddDiv();
	}else{
		//document.getElementById('regName').focus();
	}
}
//注册页面 服务条款的选择和取消
function changeCheckBox(obj){
	var btn = document.getElementById("submitBtn");
	if(obj.checked==true){
		btn.disabled = "";
		btn.style.background = "#4ea1d9";
		btn.style.border = "1px solid #4ea1d9";
	}else{
		btn.disabled = "disabled";
		btn.style.background = "#656d78";
		btn.style.border = "1px solid #656d78";
	}
}
//关闭首页登陆弹出层
function closeIndexLoginDiv(){
	document.getElementById("preAddLoginDiv").style.display = "none";
	dialogBoxHidden();
	//重置
	document.getElementById("divloginName").blur();
	document.getElementById("divloginName").value="";
	document.getElementById("divpassword").value="";
	document.getElementById("divloginName").className="infoInput_login borderNomal userImage";
	document.getElementById("divpassword").className="infoInput_login borderNomal passwordImage";
	document.getElementById("divloginNameSpan").className="";
	document.getElementById("divpasswordSpan").className="";
	document.getElementById("divloginNameSpan").innerHTML="";
	document.getElementById("divpasswordSpan").innerHTML="";
}
//返回上一页
function returnLastPage(){
	if(history.length > 1){
		history.go(-1);
	}else{
		window.location.href = "/index.do";
	}
}

/*****图片切换*****/
function indexImgeCutDiv(type){
	jQuery(function() {
		var sWidth = jQuery("#focus").width(); //获取焦点图的宽度（显示面积）
		var len = jQuery("#focus ul li").length; //获取焦点图个数
		var index = 0;
		var picTimer;
		
		//以下代码添加数字按钮和按钮后的半透明条，还有上一页、下一页两个按钮
		var btn = "";
		btn += "<div class='preNext pre'></div><div class='preNext next'></div>";
		jQuery("#focusOuter").append(btn);
		//jQuery("#focusTitle .titleList").css("opacity",1);

		//为小按钮添加鼠标滑入事件，以显示相应的内容
		if(type == 1){//保险柜
			jQuery("#focusTitle .titleList li").mouseover(function() {
				index = jQuery("#focusTitle .titleList li").index(this);
				showPics(index);
			}).eq(0).trigger("mouseover");
		}

		//上一页、下一页按钮透明度处理
		jQuery("#focusOuter .preNext").css("opacity",1).hover(function() {
			jQuery(this).stop(true,false).animate({"opacity":"1"},300);
		},function() {
			jQuery(this).stop(true,false).animate({"opacity":"1"},300);
		});

		//上一页按钮
		jQuery("#focusOuter .pre").click(function() {
			index -= 1;
			if(index == -1) {index = len - 1;}
			showPics(index);
		});

		//下一页按钮
		jQuery("#focusOuter .next").click(function() {
			index += 1;
			if(index == len) {index = 0;}
			showPics(index);
		});

		//本例为左右滚动，即所有li元素都是在同一排向左浮动，所以这里需要计算出外围ul元素的宽度
		jQuery("#focus ul").css("width",sWidth * (len));
		
		//鼠标滑上焦点图时停止自动播放，滑出时开始自动播放
		jQuery("#focus").hover(function() {
			clearInterval(picTimer);
		},function() {
			picTimer = setInterval(function() {
				showPics(index);
				index++;
				if(index == len) {index = 0;}
			},4000); //此4000代表自动播放的间隔，单位：毫秒
		}).trigger("mouseleave");
		
		//显示图片函数，根据接收的index值显示相应的内容
		function showPics(index) { //普通切换
			var nowLeft = -index*sWidth; //根据index值计算ul元素的left值
			jQuery("#focus ul").stop(true,false).animate({"left":nowLeft},300); //通过animate()调整ul元素滚动到计算出的position
			if(type == 1){
				jQuery("#focusTitle .titleList li span").removeClass("lightBlue").eq(index).addClass("lightBlue"); //为当前的按钮切换到选中的效果
			}
// 			jQuery("#focusTitle titleList li").stop(true,false).animate({"color":"#000"},300).eq(index).stop(true,false).animate({"color":"#ff0000"},300); //为当前的按钮切换到选中的效果
		}
	});
}

/****分享微博，QQ Facebook Twitter等 ****/
function sendWeibo(type){
	var url = document.getElementById("coinMainUrl").value;
	var desc;
	var summary;
	var title;
	var pic = '';
	if(type==0){
		desc =  document.getElementById("shareSummary").value;
		summary = document.getElementById("shareSummary").value;
		title = document.getElementById("shareTitle").value;
		//pic = document.getElementById("codeSpanPreUrl").value+'/image/active/okcoin_active.png';
	}
	var p = {
		url:url, /*获取URL，可加上来自分享到QQ标识，方便统计*/
		desc:desc, /*分享理由(风格应模拟用户对话),支持多分享语随机展现（使用|分隔）*/
		title:title, /*分享标题(可选)*/
		summary:summary, /*分享摘要(可选)*/
		pic:pic, /*分享图片(可选)*/
		flash: '', /*视频地址(可选)*/
		site:'', /*分享来源(可选) 如：QQ分享*/
		style:'102', 
		width:63,
		height:24
	};
	var s = [];
	for(var i in p){
		s.push(i + '=' + encodeURIComponent(p[i]||''));
	}
	var openurl = "http://service.weibo.com/share/share.php?"+s.join('&');
	window.open(openurl);
}
function sendToSeas(type){
	var url = document.getElementById("coinMainUrl").value;
	var openurl = "";
	if(type==1){//分享到facebook
		openurl = "http://www.facebook.com/sharer.php?u="+url;
	}else if(type==2){//分享到twitter
		openurl = "http://twitter.com/home/?status="+url;
	}
	
	window.open(openurl);
}

function sendQQ(type){
		var url = document.getElementById("coinMainUrl").value;
		var desc;
		var pic = '';
		var summary;
		var title;
		if(type ==0){
			desc =  document.getElementById("shareSummary").value;
			//summary = document.getElementById("shareSummary").value;
			title = document.getElementById("shareTitle").value;
			//pic = document.getElementById("codeSpanPreUrl").value+'/image/active/okcoin_active.png';
		}
		var p = {
			url:url, /*获取URL，可加上来自分享到QQ标识，方便统计*/
			desc:desc, /*分享理由(风格应模拟用户对话),支持多分享语随机展现（使用|分隔）*/
			title:title, /*分享标题(可选)*/
			summary:'', /*分享摘要(可选)*/
			pics:pic, /*分享图片(可选)*/
			flash: '', /*视频地址(可选)*/
			site:'', /*分享来源(可选) 如：QQ分享*/
			style:'102',
			width:63,
			height:24
		};
		var s = [];
		for(var i in p){
			s.push(i + '=' + encodeURIComponent(p[i]||''));
		}
		var openurl = "http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?"+s.join('&');
		window.open(openurl);
}
function sendLinkedin(type){
	var url = document.getElementById("coinMainUrl").value;
	var desc;
	var pic = '';
	var summary;
	var title;
	if(type ==0){
		desc =  document.getElementById("shareSummary").value;
		//summary = document.getElementById("shareSummary").value;
		title = document.getElementById("shareTitle").value;
		//pic = document.getElementById("codeSpanPreUrl").value+'/image/active/okcoin_active.png';
	}
	var p = {
		url:url, /*获取URL，可加上来自分享到QQ标识，方便统计*/
		desc:desc, /*分享理由(风格应模拟用户对话),支持多分享语随机展现（使用|分隔）*/
		title:title, /*分享标题(可选)*/
		summary:'', /*分享摘要(可选)*/
		pics:pic, /*分享图片(可选)*/
		flash: '', /*视频地址(可选)*/
		site:'', /*分享来源(可选) 如：QQ分享*/
		style:'102',
		width:63,
		height:24
	};
	var s = [];
	for(var i in p){
		s.push(i + '=' + encodeURIComponent(p[i]||''));
	}
	var openurl = "http://www.linkedin.com/shareArticle?mini=true&"+s.join('&');
	window.open(openurl);
}
function sendWeixinFriend(){
	document.getElementById("WeiXinLayer").style.display="block";
}
function closeWechat(){
	document.getElementById('WeiXinLayer').style.display = 'none';
}